package org.ttitfly.ttcore.dao.menu;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Component;
import org.springside.modules.orm.hibernate.HibernateDao;
import org.ttitfly.ttcore.entity.menu.SystemMenu;

/**
 * 用户对象的泛型DAO类.
 * 
 * @author calvin
 */
@Component
public class SystemMenuDao extends HibernateDao<SystemMenu, Long> {
	
	@SuppressWarnings("unchecked")
	public List<SystemMenu> getByIds(List<Long> ids) {
		Query query = getSession().createQuery("select o from SystemMenu o where o.id in (:ids) order by o.orderNum ");
		query.setParameterList("ids", ids);
		return ( List<SystemMenu> )query.list();
	}
	@SuppressWarnings("unchecked")
	public List<SystemMenu> getAllChild(Long id){
		Query query = getSession().createQuery("select o from SystemMenu o where o.id != :id  order by o.orderNum ");
		query.setParameter("id", id);
		return ( List<SystemMenu> )query.list();
	}
	
	
}
